<template>
  <div class="login-container">
    <h2>为梦成真开发者</h2>
    <form @submit.prevent="login">
      <div class="form-group">
        <label>用户名</label>
        <input v-model="username" type="text" required>
      </div>
      <div class="form-group">
        <label>密码</label>
        <input v-model="password" type="password" required>
      </div>
      <button type="submit">登录</button>
    </form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    login() {
      if (this.username === 'admin' && this.password === '123456') {
        localStorage.setItem('isLoggedIn', 'true')
        this.$router.push('/dream')
      } else {
        alert('用户名或密码错误')
      }
    }
  },
  mounted() {
    if (localStorage.getItem('isLoggedIn')) {
      this.$router.push('/dream')
    }
  }
}
</script>

<style scoped>
.login-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 20px;
}
.form-group {
  margin-bottom: 15px;
}
label {
  display: block;
  margin-bottom: 5px;
}
input {
  width: 100%;
  padding: 8px;
}
button {
  width: 100%;
  padding: 10px;
  background-color: #B0D0FC;
  color: white;
  border: none;
}
</style>